Skip to content

Chainable methods fix#134

Merged
mringler merged 3 commits intoperplorm:mainfrom
mringler:chainable_methods_fix
Mar 30, 2026
Merged

Chainable methods fix#134
mringler merged 3 commits intoperplorm:mainfrom
mringler:chainable_methods_fix

Conversation

@mringler
Copy link
Copy Markdown
Collaborator

Issue

Methods Model::setPrimaryKey()/Model::setPrimaryKeys() return void and are not chainable, even though everything else is.

Changes

Methods return $this now. This made some Spryker sniffs complain, so I removed them.
Also, the script rebuilding reference files had to be adjusted for phpunit 10.

Implementation Details

First removed sniff required methods with @return $this to explicitly do return $this;. Returning $this through another method (i.e. return $this->returnThis();) caused an error. This leads to unnecessarily elongated methods , and overall is something type checkers should handle, not linters.
I remembered previously changing types from @return $this to @return static because of this rule. I went back and adjusted those, now that the "correct" type can be used.

Second removed sniff failed to recognize the array in @param array{int, string}:

Possible doc block error: array{int, string} $keys seems to be missing type array. (Spryker.Commenting.DocBlockParamAllowDefaultValue.Typehint)

Having array shapes seems more beneficial than what the rule checks, and I think this kind of error is detected by type checkers.

Test strategy

Via reference file and lint/stan.

@mringler mringler merged commit 3a8ff53 into perplorm:main Mar 30, 2026
41 checks passed
@mringler mringler deleted the chainable_methods_fix branch March 30, 2026 03:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant